package Control;

import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

import Entity.MsgPackage;
import GUI.ExaminationStageGui;
import GUI.ScreenManager;
/**
 * Controls the instance of Examination Stage Control
 * This class sends and gets data from the server 
 * and display it on the panel.
 * @author Aviat
 *
 */ 
public class ExaminationStageControl {
	private ExaminationStageGui exam_stage_gui;
	private MsgPackage exam;
	private String[] data;
	
	/**
	 * the constructor
	 */
	public ExaminationStageControl(){
		exam_stage_gui=new ExaminationStageGui();
		exam= new MsgPackage();
		data= new String [2];
		
	}

	/**
	 * 
	 * @return ExaminationStageGui
	 */
	public ExaminationStageGui getExaminationGui() {
		 return exam_stage_gui ;
	}
	
	/**
	 * 
	 * @param ReqNum to set the request number
	 */
	public void reqANDstageEntered(String ReqNum){
		data[0]=ReqNum;
	}
	
	/**
	 * This method sends the examiner decision to the server
	 *  The server sends an answer (received from query from database) 
	 *  and the control display it in a message
	 */	
	public void examination_Submit_pressed() {
		String x= (String)exam_stage_gui.getDecision().getSelectedItem();
		if(x==null){
			JOptionPane.showMessageDialog(null, "Not all the fileds all the fill", "ERROR", JOptionPane.ERROR_MESSAGE);
		}
		else{
			data[1]=(String)exam_stage_gui.getDecision().getSelectedItem();
			exam.setObject(data);
			exam.setOp_code(OP_CODE.EXAMINATION_STAGE);
			ScreenManager.getConnection().accept(exam);
			JOptionPane.showMessageDialog(null, "Your stage was updated successfully!!", "", JOptionPane.INFORMATION_MESSAGE);

		}
		
	}

	
}
